import Request from '@/business/Request'
import type {
  InfoEchartsData,
  JurisdictionData,
  LoginData,
  LoginParams,
  MockResponse,
  UserListData,
} from '@/interfaces/RequestType' // 类型
import type { AxiosRequestConfig, AxiosResponse } from 'axios'

// 登录接口
export const loginApi = (data: LoginParams) => {
  return Request.post<MockResponse<LoginData>>('/login', data)
}
// 验证码接口
export const captchaApi = () => {
  return Request.get<AxiosResponse<string, string>>('/users/captcha')
}
// 权限接口
export const jurisdictionApi = (userInfo: LoginData) => {
  return Request.post<MockResponse<JurisdictionData[]>>('/users/jurisdiction', { userInfo })
}
// 图表信息
export const infoEchartsApi = () => {
  return Request.post<MockResponse<{ result: InfoEchartsData[] }>>('/info/dashoard')
}
// 用户列表
export const userListApi = (query: { size: number; page: number }) => {
  return Request.get<MockResponse<{ total: number; users: UserListData[] }>>('/user/list', {
    params: query,
  })
}
// 删除列表用户
export const userListRemoveApi = (query: { userId: number }) => {
  return Request.delete('/user/delete', query as AxiosRequestConfig)
}
